<template>
  <div>
    <span v-for="(item, index) in arr" :key="index"
      ><input type="checkbox" v-model="add" :value="item" />{{ item }} &nbsp;
    </span>
    <p>累加值为{{ sum }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      add: [],
    };
  },

  methods: {},
  computed: {
    sum() {
      return this.add.reduce(function(sum, current) {
        return sum + current;
      }, 0);
    },
  },
};
</script>

<style scoped></style>
